package com.jhhc.StormSurgeForecast.StormSurge.Uitl;

import com.jhhc.StormSurgeForecast.StormSurge.Pojo.FBC.BDMS_FBC_RESULT_A;
import com.jhhc.StormSurgeForecast.StormSurge.Pojo.FBC.BDMS_FBC_RESULT_S;
import com.jhhc.StormSurgeForecast.StormSurge.Pojo.GZABO.CalParaInfo;
import com.jhhc.StormSurgeForecast.StormSurge.Pojo.GZABO.ResultData;
import com.jhhc.StormSurgeForecast.StormSurge.Pojo.ZJBO.SeaWallData;
import com.jhhc.StormSurgeForecast.StormSurge.Pojo.ZJBO.valueDatas;
import org.springframework.stereotype.Component;

import java.io.File;
import java.util.*;
import java.util.function.Predicate;
import java.util.stream.Collectors;
/**
 * @author LYQ
 */
@Component
public class BinaryUtil {
    //读取文件夹下的文件
    public static List<String> getConditions(String path){
        File file = new File(path);
        File[] files = file.listFiles();
        List<String> strings = new ArrayList<>();
        if (files != null) {
            for (int i = 0; i < files.length; i++) {
                strings.add(files[i].toString());// 添加文件全路径名
            }
        }
        Predicate<String> contain = n -> n.contains("BTFUP");
        return strings.stream().filter(contain).collect(Collectors.toList());
    }
    //越浪类型分类
    public List<SeaWallData> ZJclassification(List<BDMS_FBC_RESULT_S> bdms_fbc_result_sList){
        List<SeaWallData> wallIds = new ArrayList<>();
        List<BDMS_FBC_RESULT_S> bdms_fbc_result_s1 = bdms_fbc_result_sList.
                stream().filter(BDMS_FBC_RESULT_S -> BDMS_FBC_RESULT_S.getDttp() == 1).collect(Collectors.toList());
        List<BDMS_FBC_RESULT_S> bdms_fbc_result_s6 = bdms_fbc_result_sList.
                stream().filter(BDMS_FBC_RESULT_S -> BDMS_FBC_RESULT_S.getDttp() == 6).collect(Collectors.toList());
        List<BDMS_FBC_RESULT_S> bdms_fbc_result_s10 = bdms_fbc_result_sList.
                stream().filter(BDMS_FBC_RESULT_S -> BDMS_FBC_RESULT_S.getDttp() == 10).collect(Collectors.toList());
        List<BDMS_FBC_RESULT_S> bdms_fbc_result_s11 = bdms_fbc_result_sList.
                stream().filter(BDMS_FBC_RESULT_S -> BDMS_FBC_RESULT_S.getDttp() == 11).collect(Collectors.toList());
        for (int i = 0; i < 4; i++) {
            SeaWallData seaWallData = new SeaWallData();
            List<valueDatas> valueDatas = new ArrayList<>();
            switch (i){
                case 0:
                    seaWallData.setCalDataType(Integer.toString(bdms_fbc_result_s1.get(0).getDttp()));
                    seaWallData.setUnit("m");
                    for (int j = 0; j < bdms_fbc_result_s1.size(); j++) {
                        valueDatas valueData = new valueDatas();
                        if (bdms_fbc_result_s1.get(j).getDttm() != null && !bdms_fbc_result_s1.get(j).getDttm().equals("")) {
                            valueData.setTm(bdms_fbc_result_s1.get(j).getDttm());
                        }
                        if (bdms_fbc_result_s1.get(j).getDtvalues() != null && !bdms_fbc_result_s1.get(j).getDtvalues().equals("")) {
                            valueData.setValue(bdms_fbc_result_s1.get(j).getDtvalues());
                        }
                        valueDatas.add(valueData);
                    }
                    seaWallData.setValueDatas(valueDatas);
                    break;
                case 1:
                    seaWallData.setCalDataType(Integer.toString(bdms_fbc_result_s6.get(0).getDttp()));
                    seaWallData.setUnit("m");
                    for (int j = 0; j < bdms_fbc_result_s6.size(); j++) {
                        valueDatas valueData = new valueDatas();
                        if (bdms_fbc_result_s6.get(j).getDttm() != null && !bdms_fbc_result_s6.get(j).getDttm().equals("")) {
                            valueData.setTm(bdms_fbc_result_s6.get(j).getDttm());
                        }
                        if (bdms_fbc_result_s6.get(j).getDtvalues() != null && !bdms_fbc_result_s6.get(j).getDtvalues().equals("")) {
                            valueData.setValue(bdms_fbc_result_s6.get(j).getDtvalues());
                        }
                        valueDatas.add(valueData);
                    }
                    seaWallData.setValueDatas(valueDatas);
                    break;
                case 2:
                    seaWallData.setCalDataType(Integer.toString(bdms_fbc_result_s10.get(0).getDttp()));
                    seaWallData.setUnit("");
                    for (int j = 0; j < bdms_fbc_result_s10.size(); j++) {
                        valueDatas valueData = new valueDatas();
                        if (bdms_fbc_result_s10.get(j).getDttm() != null && !bdms_fbc_result_s10.get(j).getDttm().equals("")) {
                            valueData.setTm(bdms_fbc_result_s10.get(j).getDttm());
                        }
                        if (bdms_fbc_result_s10.get(j).getDtvalues() != null && !bdms_fbc_result_s10.get(j).getDtvalues().equals("")) {
                            valueData.setValue(bdms_fbc_result_s10.get(j).getDtvalues());
                        }
                        valueDatas.add(valueData);
                    }
                    seaWallData.setValueDatas(valueDatas);
                    break;
                case 3:
                    seaWallData.setCalDataType(Integer.toString(bdms_fbc_result_s11.get(0).getDttp()));
                    seaWallData.setUnit("");
                    for (int j = 0; j < bdms_fbc_result_s11.size(); j++) {
                        valueDatas valueData = new valueDatas();
                        if (bdms_fbc_result_s11.get(j).getDttm() != null && !bdms_fbc_result_s11.get(j).getDttm().equals("")) {
                            valueData.setTm(bdms_fbc_result_s11.get(j).getDttm());
                        }
                        if (bdms_fbc_result_s11.get(j).getDtvalues() != null && !bdms_fbc_result_s11.get(j).getDtvalues().equals("")) {
                            valueData.setValue(bdms_fbc_result_s11.get(j).getDtvalues());
                        }
                        valueDatas.add(valueData);
                    }
                    seaWallData.setValueDatas(valueDatas);
                    break;
                default:
                    break;
            }
            wallIds.add(seaWallData);
        }
        return wallIds;
    }

    //港珠澳类型分类
    public ResultData GZAclassification(String Type, List<BDMS_FBC_RESULT_A> bdms_fbc_result_aList,
                                               List<BDMS_FBC_RESULT_A> bdms_fbc_result_aList1,
                                               boolean rule, String typeofpier,Integer number,String dtnm){
        ResultData resultData = new ResultData();
        List<CalParaInfo> calParaInfoList = new ArrayList<>();
        FormulaUtil formulaUtil = new FormulaUtil();
        VariableUtil variableUtil = new VariableUtil();
        switch (Type){
            case "桥墩":
                double scourAssessmentAvg = 0;
                int type = variableUtil.typeJudge(typeofpier);
                //水位  z
                List<BDMS_FBC_RESULT_A> z = bdms_fbc_result_aList.stream().
                        filter(BDMS_FBC_RESULT_A -> BDMS_FBC_RESULT_A.getDttp() == 1).collect(Collectors.toList());
                //x方向流速  u
                List<BDMS_FBC_RESULT_A> u = bdms_fbc_result_aList.stream().
                        filter(BDMS_FBC_RESULT_A -> BDMS_FBC_RESULT_A.getDttp() == 2).collect(Collectors.toList());
                //y方向流速  v
                List<BDMS_FBC_RESULT_A> v = bdms_fbc_result_aList.stream().
                        filter(BDMS_FBC_RESULT_A -> BDMS_FBC_RESULT_A.getDttp() == 3).collect(Collectors.toList());
                //波高  h
                List<BDMS_FBC_RESULT_A> h = bdms_fbc_result_aList.stream().
                        filter(BDMS_FBC_RESULT_A -> BDMS_FBC_RESULT_A.getDttp() == 6).collect(Collectors.toList());
                //波周期  m_wave_t
                List<BDMS_FBC_RESULT_A> m_wave_t = bdms_fbc_result_aList.stream().
                        filter(BDMS_FBC_RESULT_A -> BDMS_FBC_RESULT_A.getDttp() == 7).collect(Collectors.toList());
                //波向  waveDirection
                List<BDMS_FBC_RESULT_A> waveDirection = bdms_fbc_result_aList1.stream().
                        filter(BDMS_FBC_RESULT_A -> BDMS_FBC_RESULT_A.getDttp() == 8).collect(Collectors.toList());
                for (int i = 0; i < z.size(); i++) {
                    CalParaInfo calParaInfo = new CalParaInfo();
                    if (z.get(i).getDtvalues() != null && !z.get(i).getDtvalues().equals("")) {
                        double value_z = Double.parseDouble(z.get(i).getDtvalues()) / 100;
                        calParaInfo.setZ(String.format("%.2f",value_z));
                    }
                    if (u.get(i).getDtvalues() != null && !"".equals(u.get(i).getDtvalues())
                            && v.get(i).getDtvalues() != null && !v.get(i).getDtvalues().equals("")) {
                        double value_u = Double.parseDouble(u.get(i).getDtvalues()) / 100;
                        double value_v = Double.parseDouble(v.get(i).getDtvalues()) / 100;
                        String cs = variableUtil.currentSpeed(value_u,value_v);
                        calParaInfo.setV(cs);
                    }
                    if (h.get(i).getDtvalues() != null && !"".equals(h.get(i).getDtvalues())) {
                        double value_h = Double.parseDouble(h.get(i).getDtvalues()) / 100;
                        calParaInfo.setH(String.format("%.2f",value_h));
                    }
                    if (m_wave_t.get(i).getDtvalues() != null && !m_wave_t.get(i).getDtvalues().equals("")) {
                        double value_m_wave_t = Double.parseDouble(m_wave_t.get(i).getDtvalues()) / 100;
                        calParaInfo.setT(String.format("%.2f",value_m_wave_t));
                    }
                    if (waveDirection.get(i).getDtvalues() != null && !waveDirection.get(i).getDtvalues().equals("")) {
                        double value_waveDirection = Double.parseDouble(waveDirection.get(i).getDtvalues()) / 100;
                        calParaInfo.setWave(String.format("%.2f",value_waveDirection));
                    }
                    if (z.get(i).getDttm() != null && !"".equals(z.get(i).getDttm())) {
                        calParaInfo.setTm(z.get(i).getDttm());
                    }
                    if (rule) {
                        String hb = formulaUtil.HBS
                                (type,Double.parseDouble(calParaInfo.getZ()),Double.parseDouble(calParaInfo.getV()));

                        calParaInfo.setHB(hb);
                        System.out.println(calParaInfo.getHB());
                        scourAssessmentAvg += Double.parseDouble(hb);
                    }else {
                        String hb = formulaUtil.HBB
                                (type,Double.parseDouble(calParaInfo.getZ()),Double.parseDouble(calParaInfo.getT()),
                                        Double.parseDouble(calParaInfo.getH()),Double.parseDouble(calParaInfo.getV()));
                        calParaInfo.setHB(hb);
                        System.out.println(calParaInfo.getHB());
                        scourAssessmentAvg += Double.parseDouble(hb);
                    }
                    calParaInfoList.add(JudgeUtil.riskLevelJudge(Type,calParaInfo,typeofpier));
                }
                resultData.setHBAvg(String.format("%.2f",scourAssessmentAvg / z.size()));
                break;
            case "沉管":
                double erosionAndSiltationAssessmentAvg = 0;
                double coverSoilThicknessAvg = 0;
                //水位  z
                List<BDMS_FBC_RESULT_A> z1 = bdms_fbc_result_aList.stream().
                        filter(BDMS_FBC_RESULT_A -> BDMS_FBC_RESULT_A.getDttp() == 1).collect(Collectors.toList());
                //x方向流速  u
                List<BDMS_FBC_RESULT_A> u1 = bdms_fbc_result_aList.stream().
                        filter(BDMS_FBC_RESULT_A -> BDMS_FBC_RESULT_A.getDttp() == 2).collect(Collectors.toList());
                //y方向流速  v
                List<BDMS_FBC_RESULT_A> v1 = bdms_fbc_result_aList.stream().
                        filter(BDMS_FBC_RESULT_A -> BDMS_FBC_RESULT_A.getDttp() == 3).collect(Collectors.toList());
                //含沙量   sedimentConcentration
                List<BDMS_FBC_RESULT_A> sedimentConcentration = bdms_fbc_result_aList.stream().
                        filter(BDMS_FBC_RESULT_A -> BDMS_FBC_RESULT_A.getDttp() == 4).collect(Collectors.toList());
                //波高  h
                List<BDMS_FBC_RESULT_A> h1 = bdms_fbc_result_aList.stream().
                        filter(BDMS_FBC_RESULT_A -> BDMS_FBC_RESULT_A.getDttp() == 6).collect(Collectors.toList());
                //波周期  m_wave_t
                List<BDMS_FBC_RESULT_A> m_wave_t1 = bdms_fbc_result_aList.stream().
                        filter(BDMS_FBC_RESULT_A -> BDMS_FBC_RESULT_A.getDttp() == 7).collect(Collectors.toList());
                //地形冲淤  scouringAndSilting
                List<BDMS_FBC_RESULT_A> scouringAndSilting = bdms_fbc_result_aList1.stream().
                        filter(BDMS_FBC_RESULT_A -> BDMS_FBC_RESULT_A.getDttp() == 5).collect(Collectors.toList());
                //波向  waveDirection
                List<BDMS_FBC_RESULT_A> waveDirection1 = bdms_fbc_result_aList1.stream().
                        filter(BDMS_FBC_RESULT_A -> BDMS_FBC_RESULT_A.getDttp() == 8).collect(Collectors.toList());
                for (int i = 0; i < z1.size(); i++) {
                    CalParaInfo calParaInfo = new CalParaInfo();
                    calParaInfo.setCoverSoilThickness(String.format("%.2f",JudgeUtil.EnJudge(number)));
                    coverSoilThicknessAvg += Double.parseDouble(calParaInfo.getCoverSoilThickness());
                    if (z1.get(i).getDtvalues() != null && !z1.get(i).getDtvalues().equals("")) {
                        double value_z = Double.parseDouble(z1.get(i).getDtvalues()) / 100;
                        calParaInfo.setZ(String.format("%.2f",value_z));
                    }
                    if (u1.get(i).getDtvalues() != null && !u1.get(i).getDtvalues().equals("")
                    && v1.get(i).getDtvalues() != null && !v1.get(i).getDtvalues().equals("")) {
                        double value_u = Double.parseDouble(u1.get(i).getDtvalues()) / 100;
                        double value_v = Double.parseDouble(v1.get(i).getDtvalues()) / 100;
                        String cs = variableUtil.currentSpeed(value_u,value_v);
                        calParaInfo.setV(cs);
                    }
                    if (h1.get(i).getDtvalues() != null && !h1.get(i).getDtvalues().equals("")) {
                        double value_h = Double.parseDouble(h1.get(i).getDtvalues()) / 100;
                        calParaInfo.setH(String.format("%.2f",value_h));
                    }
                    if (m_wave_t1.get(i).getDtvalues() != null && !m_wave_t1.get(i).getDtvalues().equals("")) {
                        double value_m_wave_t = Double.parseDouble(m_wave_t1.get(i).getDtvalues()) / 100;
                        calParaInfo.setT(String.format("%.2f",value_m_wave_t));
                    }
                    if (waveDirection1.get(i).getDtvalues() != null && !waveDirection1.get(i).getDtvalues().equals("")) {
                        double value_waveDirection = Double.parseDouble(waveDirection1.get(i).getDtvalues()) / 100;
                        calParaInfo.setWave(String.format("%.2f",value_waveDirection));
                    }
                    if (sedimentConcentration.get(i).getDtvalues() != null && !sedimentConcentration.get(i).getDtvalues().equals("")) {
                        double value_sedimentConcentration = Double.parseDouble(sedimentConcentration.get(i).getDtvalues()) / 100;
                        calParaInfo.setCs(String.format("%.2f",value_sedimentConcentration));
                    }
                    if (scouringAndSilting.get(i).getDtvalues() != null && !scouringAndSilting.get(i).getDtvalues().equals("")) {
                        double value_scouringAndSilting = Double.parseDouble(scouringAndSilting.get(i).getDtvalues()) / 100;
                        calParaInfo.setD(String.format("%.2f",value_scouringAndSilting));
                    }
                    if (z1.get(i).getDttm() != null && !z1.get(i).getDttm().equals("")) {
                        calParaInfo.setTm(z1.get(i).getDttm());
                    }
                    if (rule) {
                        String hb = formulaUtil.HBS
                                (1,Double.parseDouble(calParaInfo.getZ()),Double.parseDouble(calParaInfo.getV()));
                        calParaInfo.setErosionAndSiltationAssessment(hb);
                        erosionAndSiltationAssessmentAvg += Double.parseDouble(hb);
                    }else {
                        String hb = formulaUtil.HBB
                                (1,Double.parseDouble(calParaInfo.getZ()),Double.parseDouble(calParaInfo.getT()),
                                        Double.parseDouble(calParaInfo.getH()),Double.parseDouble(calParaInfo.getV()));
                        calParaInfo.setErosionAndSiltationAssessment(hb);
                        erosionAndSiltationAssessmentAvg += Double.parseDouble(hb);
                    }
                    calParaInfoList.add(JudgeUtil.riskLevelJudge(Type,calParaInfo,typeofpier));
                }
                resultData.setCoverSoilThicknessAvg(String.format("%.2f",coverSoilThicknessAvg / z1.size()));
                resultData.setErosionAndSiltationAssessmentAvg(String.format("%.2f",erosionAndSiltationAssessmentAvg / z1.size()));
                break;
            case "填充岛屿":
                resultData.setA("49.80");
                resultData.setB("19.05");
                resultData.setC("2.89");
                resultData.setGamma("10.25");
                double PVAvg = 0;
                double PHAvg = 0;
                double FVAvg = 0;
                double FHAvg = 0;
                double qAvg = 0;
                double rAvg = 0;
                //水位  z
                List<BDMS_FBC_RESULT_A> z2 = bdms_fbc_result_aList.stream().
                        filter(BDMS_FBC_RESULT_A -> BDMS_FBC_RESULT_A.getDttp() == 1).collect(Collectors.toList());
                //波高  h
                List<BDMS_FBC_RESULT_A> h2 = bdms_fbc_result_aList.stream().
                        filter(BDMS_FBC_RESULT_A -> BDMS_FBC_RESULT_A.getDttp() == 6).collect(Collectors.toList());
                //波周期  m_wave_t
                List<BDMS_FBC_RESULT_A> m_wave_t2 = bdms_fbc_result_aList.stream().
                        filter(BDMS_FBC_RESULT_A -> BDMS_FBC_RESULT_A.getDttp() == 7).collect(Collectors.toList());
                //波向  waveDirection
                List<BDMS_FBC_RESULT_A> waveDirection2 = bdms_fbc_result_aList1.stream().
                        filter(BDMS_FBC_RESULT_A -> BDMS_FBC_RESULT_A.getDttp() == 8).collect(Collectors.toList());
                for (int i = 0; i < z2.size(); i++) {
                    CalParaInfo calParaInfo = new CalParaInfo();
                    if (z2.get(i).getDtvalues() != null && !"".equals(z2.get(i).getDtvalues())) {
                        double value_z = Double.parseDouble(z2.get(i).getDtvalues()) / 100;
                        calParaInfo.setZ(String.format("%.2f",value_z));
                    }
                    if (h2.get(i).getDtvalues() != null && !"".equals(h2.get(i).getDtvalues())) {
                        double value_h = Double.parseDouble(h2.get(i).getDtvalues()) / 100;
                        calParaInfo.setH(String.format("%.2f",value_h));
                        //System.out.println(calParaInfo.getH());
                    }
                    if (m_wave_t2.get(i).getDtvalues() != null && !m_wave_t2.get(i).getDtvalues().equals("")) {
                        double value_m_wave_t = Double.parseDouble(m_wave_t2.get(i).getDtvalues()) / 100;
                        calParaInfo.setT(String.format("%.2f",value_m_wave_t));
                    }
                    if (waveDirection2.get(i).getDtvalues() != null && !waveDirection2.get(i).getDtvalues().equals("")) {
                        double value_waveDirection = Double.parseDouble(waveDirection2.get(i).getDtvalues()) / 100;
                        calParaInfo.setWave(String.format("%.2f",value_waveDirection));
                    }
                    if (z2.get(i).getDttm() != null && !"".equals(z2.get(i).getDttm())) {
                        calParaInfo.setTm(z2.get(i).getDttm());
                    }
                    if (calParaInfo.getZ() != null && !"".equals(calParaInfo.getZ())) {
                        String d = variableUtil.calculationD(Double.parseDouble(calParaInfo.getZ()));//水深
                        calParaInfo.setWaterDepth(d);
                        String deltah = variableUtil.calculationDeltaH(Double.parseDouble(calParaInfo.getZ()));//净空高度
                        calParaInfo.setDeltah(deltah);
                    }
                    if (calParaInfo.getH() != null && !"".equals(calParaInfo.getH())) {
                        String etaMaxM = variableUtil.calculationEtaMax
                                (Double.parseDouble(calParaInfo.getH()),Double.parseDouble(calParaInfo.getWaterDepth()));//波峰高度
                        calParaInfo.setEtaMax(etaMaxM);
                    }
                    if (calParaInfo.getWave() != null && !"".equals(calParaInfo.getWave())) {
                        double angle = variableUtil.calculationWaveDirection
                                (Double.parseDouble(calParaInfo.getWave()));//波向桥轴线夹角
                        calParaInfo.setAngle(String.format("%.2f",angle));
                    }
                    String PV = formulaUtil.PV(Double.parseDouble(resultData.getB()),
                            Double.parseDouble(calParaInfo.getWaterDepth()), Double.parseDouble(resultData.getGamma()),
                            Double.parseDouble(calParaInfo.getH()),Double.parseDouble(calParaInfo.getT()),
                            Double.parseDouble(calParaInfo.getAngle()), Double.parseDouble(calParaInfo.getEtaMax()),
                            Double.parseDouble(calParaInfo.getDeltah()),rule);
                    if (Double.parseDouble(PV) < 0) {
                        calParaInfo.setPV("0.00");
                    }else {
                        calParaInfo.setPV(PV);
                    }
                    PVAvg += Double.parseDouble(calParaInfo.getPV());

                    String PH = formulaUtil.PH(Double.parseDouble(calParaInfo.getWaterDepth()),
                            Double.parseDouble(resultData.getGamma()), Double.parseDouble(calParaInfo.getH()),
                            Double.parseDouble(calParaInfo.getT()), Double.parseDouble(calParaInfo.getAngle()),
                            Double.parseDouble(calParaInfo.getEtaMax()), Double.parseDouble(calParaInfo.getDeltah()),rule);
                    if (Double.parseDouble(PH) < 0) {
                        calParaInfo.setPH("0.00");
                    }else {
                        calParaInfo.setPH(PH);
                    }
                    PHAvg += Double.parseDouble(calParaInfo.getPH());

                    String FV = formulaUtil.FV(Double.parseDouble(resultData.getA()),
                            Double.parseDouble(resultData.getB()),Double.parseDouble(calParaInfo.getWaterDepth()),
                            Double.parseDouble(resultData.getGamma()), Double.parseDouble(calParaInfo.getH()),
                            Double.parseDouble(calParaInfo.getT()), Double.parseDouble(calParaInfo.getAngle()),
                            Double.parseDouble(calParaInfo.getEtaMax()), Double.parseDouble(calParaInfo.getDeltah()),rule);
                    if (Double.parseDouble(FV) < 0) {
                        calParaInfo.setFV("0.00");
                    }else {
                        calParaInfo.setFV(FV);
                    }
                    FVAvg += Double.parseDouble(calParaInfo.getFV());
                    String FH = formulaUtil.FH(Double.parseDouble(resultData.getA()),
                            Double.parseDouble(resultData.getC()), Double.parseDouble(calParaInfo.getWaterDepth()),
                            Double.parseDouble(resultData.getGamma()), Double.parseDouble(calParaInfo.getH()),
                            Double.parseDouble(calParaInfo.getT()), Double.parseDouble(calParaInfo.getAngle()),
                            Double.parseDouble(calParaInfo.getEtaMax()), Double.parseDouble(calParaInfo.getDeltah()),rule);
                    if (Double.parseDouble(FH) < 0) {
                        calParaInfo.setFH("0.00");
                    }else {
                        calParaInfo.setFH(FH);
                    }
                    FHAvg += Double.parseDouble(calParaInfo.getFH());

                    calParaInfo.setEl("3");
                    calParaInfo.setM("2");
                    calParaInfo.setB("12");
                    calParaInfo.setBc("5.7");
                    calParaInfo.setCl("8");
                    String d = variableUtil.calculationD(Double.parseDouble(calParaInfo.getZ()));
                    String l = variableUtil.calculationL(Double.parseDouble(d),
                            Double.parseDouble(calParaInfo.getT()));
                    String rc = variableUtil.Rc(Double.parseDouble(calParaInfo.getZ()));
                    String kc = variableUtil.Kc(5.7);
                    String db = variableUtil.dB(Double.parseDouble(calParaInfo.getZ()));
                    String kb = variableUtil.Kb(Double.parseDouble(calParaInfo.getH()),Double.parseDouble(db));
                    String kexi = variableUtil.kexi1(Double.parseDouble(calParaInfo.getH()),
                            Double.parseDouble(l));
                    String q = formulaUtil.Q(Double.parseDouble(calParaInfo.getH()),Double.parseDouble(kc),
                            Double.parseDouble(kb),Double.parseDouble(kexi),Double.parseDouble(rc));
                    qAvg += Double.parseDouble(q);
                    calParaInfo.setQ(q);

                    String r = formulaUtil.RF(Double.parseDouble(kb),Double.parseDouble(kexi),4);
                    rAvg += Double.parseDouble(r);
                    calParaInfo.setR(r);

                    calParaInfoList.add(JudgeUtil.riskLevelJudge(Type,calParaInfo,typeofpier));

                }
                resultData.setPVAvg(String.format("%.2f",PVAvg / z2.size()));
                resultData.setPHAvg(String.format("%.2f",PHAvg / z2.size()));
                resultData.setFVAvg(String.format("%.2f",FVAvg / z2.size()));
                resultData.setFHAvg(String.format("%.2f",FHAvg / z2.size()));
                resultData.setRAvg(String.format("%.2f",rAvg / z2.size()));
                resultData.setQAvg(String.format("%.4f",qAvg / z2.size()));
                break;
            default:
                break;
        }
        resultData.setCalParaInfoList(calParaInfoList);
        resultData.setDtnm(dtnm);
        return resultData;
    }

}
